package org.witsoft.localmq;

import lombok.Getter;
import org.witsoft.localmq.impl.*;

/**
 * @ClassName: LogInstanceFactory
 * @Description:
 * @Author: Colin
 * @Date: 2020/12/26 12:56 PM
 * @Version 1.0
 **/
public class MqInstanceFactory {

    private ConfigManager configManager;

    private FileManager fileManager;

    private FileWriter fileWriter;

    private FileReader fileReader;

    private QueuedMessageBroker messageBroker;

    @Getter
    private OffsetManager offsetManager;

    @Getter
    private MessageManager messageManager;

    @Getter
    private StatsService statsService;

    public MqInstanceFactory(ConfigManager configManager){
        this.configManager = configManager;
        this.fileManager = new FileManagerImpl(this.configManager);
        this.fileWriter = new FileWriteImpl(this.fileManager);
        this.fileReader = new FileReaderImpl(this.fileManager);
        this.offsetManager = new OffsetManagerImpl(this.configManager, this.fileManager);
        this.messageBroker = new QueuedMessageBroker(this.configManager, fileWriter);
        this.messageManager = new MessageManagerImpl(this.offsetManager, this.fileWriter, this.fileReader,  this.messageBroker);
        this.statsService = new StatsServiceImpl(this.messageBroker, this.offsetManager);
    }
}
